import { sysIdeologicalEducationDelete } from "@/api/admin/system/sysIdeologicalEducation.js";
export const TreeDelete = {
    methods: {
        remove(node, data) {
            this.$confirm("确定要删除吗?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.handleDelete(node, data);
                })
                .catch(() => { });
        },
        //删除节点
        handleDelete(node, data) {
            sysIdeologicalEducationDelete(data.id).then((res) => {
                this.$message({
                    message: "操作成功",
                    type: "success",
                });
                if (data.type != 3) {
                    const parent = node.parent;
                    const children = parent.data.childList || parent.data;
                    const index = children.findIndex((d) => d.id === data.id);
                    children.splice(index, 1);
                } else {
                    this.getList();
                }

            });
        },
    },
}